<!DCOTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>A/B测试版本管理</title>
        <link rel="stylesheet" href="/css/theme/font-awesome.min.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/bootstrap.min.css" type="text/css" />
        <link rel="stylesheet" href="/javascript/theme/libs/jquery-easyui-1.4/themes/default/easyui.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/App.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/custom.css" type="text/css" />
        <script src="/javascript/theme/libs/jquery-1.9.1.min.js"></script>
        <script src="/javascript/theme/libs/jquery-easyui-1.4/jquery.easyui.min.js"></script>
        <script src="/javascript/theme/libs/bootstrap.min.js"></script>
        <script src="/javascript/theme/App.js"></script>
        <script type="text/javascript" src="/javascript/My97DatePicker/WdatePicker.js"></script>
        <script type="text/javascript" src="/javascript/report/FusionCharts.js"></script>
        <script type="text/javascript" src="../javascript/report/Date.js"></script>
        <style type="text/css">
            .alink {
            text-decoration:underline;
            color:#0000CC;
            }
            .alinkClicked {
            color:#0000CC;
            }
            #cates,#locals,#cateClean,#localClean{
            display:none;
            }
        </style>
    </head>

    <body>
    <div id="content" style="OVERFLOW-X:yes;OVERFLOW-Y:auto">

        <div id="content-container">
            <form action="/datareport/abtest" class="form-horizontal" name="searchform" role="form" method="post">
            <div class="portlet">
                <div class="portlet-header">
                    <h3>
                          <i class="fa fa-tasks"></i>
                          A/B测试版本管理
                     </h3>
                </div>

            <div class="portlet-content">
  
                <div class="form-group">
                     <label class="col-md-2" for="businessline">业务线：</label>
                        <div class="col-md-2">
                            <select id="businessline" name="businessline" class="form-control" style="align:center;width:100px ">      
                             #foreach($buss in $businessList)             
                                <option value="$buss" #if("$buss" == $!businessline) selected #end>$business_CN_Map.get("$buss")</option>
                             #end
                            </select> 
                        </div>                    

          
                    <label class="col-md-2" for="pagetype">页面类型：</label>
                      <div class="col-md-2">
                           <select id="pagetype" name="pagetype" class="form-control" style="align:center; width:100px; ">
                             #foreach($page in $pagelist)             
                                <option value="$page" #if("$page" == $!pagetype) selected #end>$pageMap.get("$page")</option>
                             #end
                        </select>   
                     </div>        
             
             
                    <label class="col-md-2" for="businessline">平台：</label>
                      <div class="col-md-2">
                            <select id="platform" name="platform" class="form-control" style="align:center; width:100px; ">
                            <option value="pc" #if($platform=="pc") selected #end>pc</option>
                            <option value="m" #if($platform=="m") selected #end>m</option>
                         </select>   
                    </div> 

                    
                    <div class="col-md-2">&nbsp;                             
                        <button type="button" id="query" name="query" onclick="querydata()" class="btn btn-primary btn-xs">查询版本码</button>
                    </div> 
                    
                  
                    <label class="col-md-2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;或者根据oa账号搜索:</label>
                        <div class="col-md-2">
                        <input type="text" class="form-control" style="width:100px" name="search_text" id="search_text" value="$!{search_text}" />
                        </div>

                        <div class="col-md-2"> &nbsp;
                            <button type="button" id="search_button" name="search_button" onclick="searchdata()" class="btn btn-primary btn-xs">搜索</button>
                        </div>

                </div>

                <div class="form-group">
                     <div > &nbsp;&nbsp;&nbsp;&nbsp;</div>
                </div>

                <div class="form-group">
                    <label class="col-md-2">上线备注: 
                    </label>
                    <div class="col-md-2">
                    <input type="text" class="form-control" style="width:255px" name="mark" id="mark" value="$!{mark}" />
                    </div>

                    <div class="col-md-2"> &nbsp;
                    <button type="button" id="add" name="add" onclick="adddata()" class="btn btn-primary btn-xs">添加版本码</button>
                    </div>
                </div>

                <textarea style="width:100px;height:20px"  hidden="hidden"  name="selecttype" id="selecttype" value="$!{selecttype}" >$!{selecttype}</textarea>  


            </div><!--portlet-content-->
            </div><!--portlet-->
</form>


 #if($rsList)
<div class="portlet">
    <div class="portlet-header">
        <h3>
            <i class="fa fa-hand-o-up"></i>
            查询结果
        </h3>
        <input type='hidden' id='curPage' #if($pageindex) value="$pageindex" #else value="0" #end/>
    </div>
        <div class="portlet-content">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover" id="wordtable" data-provide="datatable" data-display-rows="20" >
                    <thead>
                        <tr>                         
                            <th  style="text-align:center;">业务线</th>
                            <th  style="text-align:center;">页面类型</th>
                            <th  style="text-align:center;">平台</th>
                            <th  style="text-align:center;">版本码</th>
                            <th  style="text-align:center;">创建者</th>
                            <th  style="text-align:center;">创建时间</th>
                            <th  style="text-align:center;">备注</th>                     
                        </tr>
                    </thead>
                    <tbody>
                        #foreach($rs in $rsList)
                            <tr  align="center" >                           
                                <td>$!rs.businessline</td>
                                <td>$!rs.pagetype</td>
                                <td>$!rs.platform</td>
                                <td>$!rs.versioncode</td>
                                <td>$!rs.creater</td>
                                <td>$!rs.createrTime</td>
                                <td>$!rs.mark</td>
                            </tr>
                        #end												
                    </tbody>
                </table>
                <div class="row dt-rb">
                            #parse("/views/default/newpage.vm")
                            #if($!{selecttype}=="query")                            
                                 #pagenew($pList "/datareport/abtest?#page#&$paramurl")
                            #else
                                #pagenew($pList "/datareport/abtest/search?#page#&$paramurl")
                            #end
                </div>	
            </div>
        </div>
</div>
 #end
</div>
</div>


<script >
    
    function querydata(){
        document.getElementById('selecttype').value="query";
        searchform.submit();
        document.getElementById('selecttype').value="";
    }

    function adddata(){
        
        if($("#mark").val()=="")
        {
            alert("请填写上线备注!");
        }
        else
        {
            document.getElementById('selecttype').value="add";
       
            var businessline = document.getElementById('businessline').value;
            var pagetype = document.getElementById('pagetype').value;
            var platform = document.getElementById('platform').value;
            var mark = document.getElementById('mark').value;

            jQuery.ajax({
                 url:"$!{__beat.server.contextPath}/datareport/abtest/add",
                 type:"post",
                 async:true,
                 data:{"businessline":businessline,"pagetype":pagetype,"platform":platform,"mark":mark},
                        success:function(data){
                            if(data == "error"){
                                alert("操作失败！");
                            }else if(data == "success"){
                                alert("添加版本码成功！");

                                var paramurl2 ="&businessline="+businessline+"&pagetype="+pagetype+"&platform="+platform+"&selecttype=query";

                                window.location.href="$!{__beat.server.contextPath}/datareport/abtest?pageindex=" + $('#curPage').val()+paramurl2; 
                                  
                            }else{
                                alert(date);
                            }
                        }
                    });
            
            document.getElementById('selecttype').value="";      
        }  
    }

    var papelist_other=['index','list','detail','post'];

    var map={
        index:'大类页',
        list:'列表页',
        detail:'详情页',
        post:'发布页',
        home:'首页'
    };

//绑定businessline的change事件 papelist改变
   $(function(){
   $("#businessline").change(function(){
      var businessline = $("#businessline").val();
         
      var plist = "";
      if(businessline=='total')
      {
        plist = "<option value='home'>"+map["home"]+"</option>";
      }
      else 
      {
        for(p in papelist_other)
        {
            var t=papelist_other[p];
            var temp=map[t];
            plist = plist + "<option value='"+t+"'>"+temp+"</option>";
        }
      } 
       $("#pagetype").empty().append(plist);
      });
    });


     function searchdata(){
                    
       if($("#search_text").val()=="")
        {
            alert("请填写oa账号!");
        }else
        {
            var creater = document.getElementById('search_text').value;
            var paramurl2 ="&creater="+creater;
            window.location.href="$!{__beat.server.contextPath}/datareport/abtest/search?pageindex=" + $('#curPage').val()+paramurl2;         
        }  
    } 

</script>
</body>
</html>
